import React from 'react';
import { Actions } from "react-native-router-flux";
import Result from '../../../components/Result';
import Button from '../../../components/Button';

export default ({ data = {} }) => {
  const { customerId, name } = data;
  const toDetail = () => {
    /* TODO
     本来打算使用Actions.replace('customerDetail', {customerId: id});
     但是属性传递有问题, 而且并没有达到replace的效果, 还是push了路由;
     所以先pop回去, 再push新的路由;
      // Actions.replace('customerDetail', { customerId })
    */
    Actions.pop();
    Actions.customerDetail({customerId});
  };
  return (
    <Result
      title="操作成功"
      msg={`新建客户 - ${name}`}
    >
      <Button
        type="primary"
        title="再添加一个客户"
        onPress={() => Actions.replace('createCustomerBase')}
        style={{ marginBottom: 10 }}
      />
      <Button
        type="success"
        title="进一步完善客户信息"
        onPress={() => Actions.replace('editCustomerExtra', { customerId })}
        style={{ marginBottom: 10 }}
      />
      <Button
        type="normal"
        title="查看客户详情"
        onPress={toDetail}
        style={{ marginBottom: 10 }}
      />
      <Button
        type="normal"
        title="返回"
        onPress={Actions.pop}
      />
    </Result>
  );
};